package com.ysd.common.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

@Component
public class RedisUtils {
    @Autowired
    private static JedisPool jedisPool;


    public static void  set(String key,String value){
        Jedis jedis = new Jedis("127.0.0.1",6379);
        //jedis = jedisPool.getResource();
        jedis.set(key,value);
    }


    public static String  get(String key){
        Jedis  jedis = new Jedis("127.0.0.1",6379);
        try {
            //jedis = jedisPool.getResource();
            return jedis.get(key);
        }finally {
            jedis.close();
        }

    }
}
